import React, { PureComponent } from 'react';
// import { request } from './network/request'
import axios from 'axios'

class App extends PureComponent {
  constructor(props) {
    super(props);

    this.state = {

    }
  }

  async componentDidMount() {
    // 执行 请求网络、DOM操作、订阅 等操作

    // request({
    //   url: 'https://httpbin.org/get',

    // }).then(res => {
    //   console.log(res)
    // })

    // request({
    //   url: 'https://httpbin.org/post',
    //   method: "post",
    //   data: {
    //     name: "kobe", 
    //     age: 30
    //   }
    // }).then(res => {
    //   console.log(res)
    // })

    // try {
    //   const resule = await axios.get("https://httpbin.org/getaaa");
    //   console.log(resule);
    // } catch (error) {
    //   console.log("error");
    // }

    const request1 = axios({
      url: "https://httpbin.org/get",
      params: {
        name: "why",
        age: 18
      }
    })

    const request2 = axios({
      url: "https://httpbin.org/postaa",
      method: "POST",
      data: {
        name: "kobe",
        age: 40
      }
    })

    axios.all([request1, request2]).then(([res1,res2]) => {
      console.log(res1);
      console.log(res2);
    }).catch( (err) => {
      console.log(err);
    })



  }

  render() {
    return (
      <div>
        App
      </div>
    );
  }
}

export default App;
